home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Palettes / CVS / CVSPalette.m < prev    next >
Text File  |  1995-06-12  |  1KB  |  59 lines

  1. /*
  2.  * Bob_Vadnais@pdh.com Sun Jun 27 13:46:11 PDT 1993
  3.  *
  4.  * Interface Builder palette that preserves the CVS directory inside a 
  5.  * nib documement.
  6.  *
  7.  * Wouldn't it be nice if all apps had a document controller paradigm?
  8.  * Then we could solve this same problem with Edit wiping out the CVS
  9.  * directory inside .rtfd documents.
  10.  */
  11.  
  12. #import "CVSPalette.h"
  13.  
  14. @implementation CVSPalette
  15.  
  16. extern char *sys_errlist[];
  17.  
  18. #define TAR "gnutar"
  19.  
  20. - finishInstantiate
  21. /*
  22.  * Register ourselves as an IBDocumentController so we will receive
  23.  * didSaveDocument: messages from IB whenever the user saves a document.
  24.  *
  25.  * Due to an apparent bug in IB, we won't get registered correctly if
  26.  * we're autoloaded at IB launch time, hence the delayed registration.
  27.  */
  28. {
  29.     [NXApp perform:@selector(registerDocumentController:) 
  30.      with:self afterDelay:10000 cancelPrevious:NO];
  31.      
  32.     return self;
  33. }
  34.  
  35. - didSaveDocument:theDocument
  36. {
  37.     char path[MAXPATHLEN+10];
  38.     int pathlen;
  39.  
  40.     [theDocument getDocumentPathIn:path];
  41.     pathlen = strlen(path);
  42.     strcpy(path + pathlen, "~/CVS");
  43.  
  44.     if (access(path, R_OK|X_OK) == 0) {
  45.  
  46.         char cmdbuf[MAXPATHLEN * 2 + 32];
  47.         path[pathlen] = 0;          // Chop off the ~/CVS we added
  48.         sprintf(cmdbuf, TAR " cCf %s~ - CVS | " TAR " xpCf %s -", path, path);
  49.         if (system(cmdbuf) < 0) {
  50.             NXRunAlertPanel("Error", "Unable to copy %s~/CVS into %s: %s",
  51.              0, 0, 0, path, path, sys_errlist[errno]);
  52.         }
  53.     }
  54.  
  55.     return self;
  56. }
  57.  
  58. @end
  59.